package com.swak.mybatis;

import java.time.LocalTime;

import org.junit.Test;

import com.swak.mybatis.entity.Goods;
import com.swak.mybatis.mapper.GoodsMapperPlus;

/**
 * MyBatis 通过xml的方式来查询数据
 * 
 * @author lifeng
 * @date 2021年1月21日 上午10:46:41
 */
public class MybatisTestNoJUtils extends MyBatisTest {

	@Test
	public void test() {
//		GoodsMapper goodsMapper = sqlSessionTemplate.getMapper(GoodsMapper.class);
//
////		goodsMapper.delete(new Goods().setId(1L));
////		
//		// 插入数据
//		Goods get = goodsMapper.get(1L);
//		if (get == null) {
//			Goods save = new Goods();
//			save.setId(1L);
//			save.setName("收集");
//			save.setRemarks("备注");
//			save.setMessage(new byte[] { 1, 2, 3, 4 });
//			goodsMapper.insert(save);
//		} else {
//			Goods update = new Goods();
//			update.setName("收集2");
//			goodsMapper.updative(Updative.of().update("MESSAGE").update("NAME", "收集2")
//					.update("BEGIN_TIME", LocalTime.now()).andEqualTo("ID", 1L));
//		}

		// plus
		GoodsMapperPlus goodsMapperPlus = plusSessionTemplate.getMapper(GoodsMapperPlus.class);
		goodsMapperPlus.insert(new Goods().setId(1L).setName("111").setBeginTime(LocalTime.now()));
		Goods goods = goodsMapperPlus.selectById(1L);
		System.out.println(goods);
	}

	public static void main(String[] args) throws Exception {
		MybatisTestNoJUtils test = new MybatisTestNoJUtils();
		test.init();
		test.test();
	}
}